package j07menthod;


public class J1 {
    static int count = 100;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while (count>0){
                sale();
            }
        },"t1");
        Thread t2 = new Thread(()->{
            while (count>0){
                sale();
            }
        },"t2222");
        t1.start();
        t2.start();

    }
    //同步方法
    //锁，当前类的class属性当成锁
    private static synchronized void sale(){
        System.out.println(Thread.currentThread().getName()+"卖出="+count);
        count--;
    }
}
